<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        const boolean=new Boolean(false)
        console.log(typeof boolean)//objct
        console.log(boolean.valueOf())//false
        if(boolean.valueOf()){
            console.log('执行')
        }

        let number=99
        if(number)console.log('执行')//执行

        let number2=0
        if(number2==false)console.log('执行2')//执行2

        let number3=99
        if(number3==true)console.log('执行3')//不执行 只有1和0会进行判断

        if(number3)console.log('执行4')//会执行

        //表达式运行会默认执行Boolean(number)



    </script>

    <script>

        let arr=[1]
        console.log(Number(arr))//1  数组里面有多个值则会初NaN
        console.log(arr==true)//true

        let arr2=[]
        console.log(Number(arr2))//0
        console.log(arr2==false)//true

        // 对于空数组[]或者空对象{} 直接判断 会是true
        console.log(Boolean([]))//true
        console.log(Boolean({}))//true
        if([]||{})console.log('执行')//执行
    </script>
    

    <script>
        // 转换类型
        let num=0
        console.log(typeof num)//number
        num=!!num
        console.log(num)//false
        console.log(Boolean(num))//false

        let str='nihao'
        console.log(!!str)//true
        console.log(Boolean(str))//true

        let array=[] //对象同理
        console.log(!!array)//true
        console.log(Boolean(array))//true
    </script>
</body>
</html>